using SharpDX.Direct3D11;
using System;

namespace Engine.Graphics.Shaders.Wr2Shaders
{
    public class VertexColorShader : ShaderBase, ISetShaderValues
    {
        #region Private Fields

        private uint lastHashcodeMappingMatrix1 = 0;
        private uint lastHashcodeMappingMatrix2 = 0;
        private uint lastHashcodeMappingMatrix3 = 0;
        private int lastTextureID1 = -1;
        private int lastTextureID2 = -1;
        private int lastTextureID3 = -1;
        private string name;

        #endregion Private Fields

        #region Public Constructors

        public VertexColorShader(Device renderDevice, string shaderDirectory, ShaderManager shaderManager)
            : base(renderDevice, shaderManager)
        {
            this.name = shaderDirectory;
            base.LoadShader(renderDevice, shaderDirectory + "\\VertexColor.fx", "ps_main", "vs_main");
            this.inputLayout = new InputLayout(renderDevice, this.shaderByteCodeVS, Graphics.VertexStructures.Wr2VertexElements.elements);
        }

        #endregion Public Constructors

        #region Public Properties

        public ShaderBase Effect
        {
            get { return this.effect; }
        }

        public string Name
        {
            get
            {
                return this.name;
            }
            set
            {
                throw new NotImplementedException();
            }
        }

        #endregion Public Properties

        #region Public Methods

        public new void Dispose()
        {
            base.Dispose();
        }

        public void SetProperties(int materialID, MaterialManager materialManager)
        {
            //Material material = materialManager.GetMaterial(materialID);
            ////effect.SetValue("paintHighLines", false);
            //if (this.lastTextureID1 != materialManager.GetTextureID(material.TextureName1))
            //{
            //    this.lastTextureID1 = materialManager.GetTextureID(material.TextureName1);
            //}
            //if (this.lastTextureID2 != materialManager.GetTextureID(material.TextureName2))
            //{
            //    this.lastTextureID2 = materialManager.GetTextureID(material.TextureName2);
            //}
            //if (this.lastTextureID3 != materialManager.GetTextureID(material.TextureName3))
            //{
            //    this.lastTextureID3 = materialManager.GetTextureID(material.TextureName3);
            //}
            //if (material.Mappings1.CRC != this.lastHashcodeMappingMatrix1)
            //{
            //    this.lastHashcodeMappingMatrix1 = material.Mappings1.CRC;
            //}
            //if (material.Mappings2.CRC != this.lastHashcodeMappingMatrix2)
            //{
            //    this.lastHashcodeMappingMatrix2 = material.Mappings2.CRC;
            //}
            //if (material.Mappings3.CRC != this.lastHashcodeMappingMatrix3)
            //{
            //    this.lastHashcodeMappingMatrix3 = material.Mappings3.CRC;
            //}
        }

        #endregion Public Methods
    }
}